app.controller('brandController',function($scope,$controller,pygService){
    //利用伪继承实现代码的共享
    $controller("baseController",{$scope:$scope});


    //查询品牌列表
    $scope.findAll=function(){
        pygService.findAll().success(
            function(response){
                $scope.list=response;
            }
        );
    }

    //分页
    $scope.findPage=function(page,size){
        pygService.findPage(page,size).success(
            function(response){
                $scope.list=response.rows;//显示当前页数据
                $scope.paginationConf.totalItems=response.total;//更新总记录数
            }
        );
    }

    //新增
    $scope.save=function(){
        var obj=null;//对象
        if($scope.entity.id!=null){
            obj=pygService.add($scope.entity);
        }else{
            obj=pygService.update($scope.entity);
        }
        obj.success(
            function(response){
                if(response.success){
                    $scope.reloadList();//刷新
                }else{
                    alert(response.message);
                }
            }
        );
    }

    //查询实体
    $scope.findOne=function(id){
        pygService.findOne(id).success(
            function(response){
                $scope.entity=response;
            }
        );
    }



    //删除
    $scope.dele=function(){


        if(confirm('确定要删除吗？')){
            pygService.dele($scope.selectIds).success(
                function(response){
                    if(response.success){
                        $scope.reloadList();//刷新
                    }else{
                        alert(response.message);
                    }
                }
            );
        }

    }

    $scope.searchEntity={};
    //条件查询
    $scope.search=function(page,size){

        pygService.search(page,size, $scope.searchEntity).success(
            function(response){
                $scope.list=response.rows;//显示当前页数据
                $scope.paginationConf.totalItems=response.total;//更新总记录数
            }
        );

    }


});